/*    */ package com.zimbra.cs.account.callback;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.AttributeCallback;
/*    */ import com.zimbra.cs.account.AttributeCallback.SingleValueMod;
/*    */ import com.zimbra.cs.account.Entry;
/*    */ import com.zimbra.cs.account.auth.AuthMechanism.AuthMech;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class AuthMech
/*    */   extends AttributeCallback
/*    */ {
/*    */   public void preModify(CallbackContext context, String attrName, Object attrValue, Map attrsToModify, Entry entry)
/*    */     throws ServiceException
/*    */   {
/* 36 */     AttributeCallback.SingleValueMod mod = singleValueMod(attrName, attrValue);
/* 37 */     if (mod.setting()) {
/* 38 */       String authMech = mod.value();
/*    */       
/* 40 */       boolean valid = false;
/*    */       
/* 42 */       if (authMech == null) {
/* 43 */         valid = true;
/* 44 */       } else if (authMech.startsWith(AuthMechanism.AuthMech.custom.name())) {
/* 45 */         valid = true;
/*    */       } else {
/*    */         try {
/* 48 */           AuthMechanism.AuthMech mech = AuthMechanism.AuthMech.fromString(authMech);
/* 49 */           valid = true;
/*    */         } catch (ServiceException e) {
/* 51 */           ZimbraLog.account.error("invalud auth mech", e);
/*    */         }
/*    */       }
/*    */       
/* 55 */       if (!valid) {
/* 56 */         throw ServiceException.INVALID_REQUEST("invalud value: " + authMech, null);
/*    */       }
/*    */     }
/*    */   }
/*    */   
/*    */   public void postModify(CallbackContext context, String attrName, Entry entry) {}
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/account/callback/AuthMech.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */